package org.dce.screencapturer.actions.objects;

import java.awt.Font;
import java.awt.font.TextAttribute;
import java.text.AttributedCharacterIterator.Attribute;
import java.util.HashMap;
import java.util.Map;

import org.dce.screencapturer.util.IconFactory;

@SuppressWarnings("serial")
public class SetFontBoldAction 
	extends FontAction {


	public SetFontBoldAction() {
		super("actions.toggleBold", IconFactory.getIcon("/images/format-text-bold.png"));
	}

	@Override
	protected Font modifyFont(Font font) {
		
		boolean bold = TextAttribute.WEIGHT_BOLD.equals(font.getAttributes().get(TextAttribute.WEIGHT));

		Map<Attribute,Object> attributes = new HashMap<Attribute, Object>(font.getAttributes());

		if (bold){
			attributes.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_REGULAR); 
		} else {
			attributes.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);
		}

		return font.deriveFont(attributes);
	}

}
